package com.navidove.appspotlight.model.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.navidove.appspotlight.model.bo.AppDictionary;
import com.navidove.appspotlight.model.dao.AppDictionaryDao;
import com.navidove.appspotlight.model.service.AppDictionaryService;

@Service
public class AppDictionaryServiceImpl implements AppDictionaryService {

	@Autowired
	private AppDictionaryDao appDictionaryDao;
	
	@SuppressWarnings("unchecked")
	public List<AppDictionary> getAppDictionaryList(String dictionaryType) {

		DetachedCriteria criteria = DetachedCriteria.forClass(AppDictionary.class);
		criteria.add(Restrictions.eq("dictionaryType", dictionaryType));
		criteria.add(Restrictions.eq("enable", Boolean.TRUE));
		criteria.addOrder(Order.asc("dictionarySeq"));
		return (List<AppDictionary>) appDictionaryDao.getListByCriteria(criteria);
	}
}
